<?php
// +----------------------------------------------------------------------
// | ThinkCMF [ WE CAN DO IT MORE SIMPLE ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013-2018 http://www.thinkcmf.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: 老猫 <thinkcmf@126.com>
// +----------------------------------------------------------------------
namespace app\portal\controller;

use cmf\controller\HomeBaseController;
use think\Db;
session_start();

class IndexController extends HomeBaseController
{
    public function index()
    {
    	//查询非热门新闻
    	$map = array(
			'cate'=>13,
			're'  =>0
    		);
    	$newsList=Db::table('el_zy_topic')->where($map)->order('dateline desc')->select();//查询非热门新闻

    	//查询热门新闻
    	$remap = array(
    		'cate' => 13,
    		're'   => 1
    		);
    	$renewsList = Db::table('el_zy_topic')->where($remap)->order('dateline desc')->select();//查询热门新闻

    	//查询资源库
    	$time=time();
    	$limit=4;
    	$where = "is_del=0 AND is_activity=1 AND uctime>$time AND listingtime<$time";
		$video_list = Db::table('el_zy_video')->where($where)->order('ctime desc')->limit($limit)->select();

		//获取提问列表
		$wendaList = Db::table('el_zy_wenda')->where('DATE_SUB(CURDATE(), INTERVAL 7 DAY) <= ctime and is_del=0')->order('wd_comment_count desc')->limit(6)->select();

		$this->assign('video_list',$video_list);
    	$this->assign('newsList',$newsList);
    	$this->assign('renewsList',$renewsList);
    	$this->assign('wendaList',$wendaList);

        return $this->fetch(':index');
    }

    public function logout()
    {
    	unset($_SESSION['think']);
    	$this->redirect($_SERVER['HTTP_REFERER']);
    }
}
